package cn.abcsys.cloud.devops.runtime.controller;

import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import cn.abcsys.cloud.devops.runtime.bean.Result;
import cn.abcsys.cloud.devops.runtime.entity.ClusterEnv;
import cn.abcsys.cloud.devops.runtime.service.ClusterEnvService;
import net.sf.json.JSONObject;


/**
 * 环境管理控制器
 * @author mayunhao
 *
 */
@RestController
@RequestMapping("/clusterEnv")
public class ClusterEnvController {
//	private static final Logger LOGGER = Logger.getLogger(ClusterEnvController.class);
//	@Autowired
//	private ClusterEnvService clusterEnvService;
//	@RequestMapping(value = "/getEnvByClusterId", method = { RequestMethod.GET })
//	@ResponseBody
//	public Result getByCluster(@RequestParam(value = "clusterId", required = true)Integer clusterId){
//		return clusterEnvService.getEnvByCluster(clusterId);
//	}
//	@RequestMapping(value = "/getClusterByEvnId", method = { RequestMethod.GET })
//	@ResponseBody
//	public Result getByEnv(@RequestParam(value = "envId", required = true)Integer envId){
//		return clusterEnvService.getClusterByEnv(envId);
//	}
//	@RequestMapping(value = "/create", method = { RequestMethod.GET })
//	@ResponseBody
//	public Result create(@RequestParam Map<String,Object> params){
//		if(params.isEmpty()){
//			LOGGER.error("请求参数为空");
//			return new Result(false, "请求参数为空");
//		}else{
//			ClusterEnv clusterEnv = new ClusterEnv();
//			try{
//				JSONObject orig = JSONObject.fromObject(params);
//				clusterEnv = (ClusterEnv)JSONObject.toBean(orig,ClusterEnv.class);
//			}catch(Exception e){
//				LOGGER.error("请求参数转换错误："+e.getMessage());
//				return new Result(false, "请求参数转换错误："+e.getMessage());
//			}
//			return clusterEnvService.createCLusterEnv(clusterEnv);
//		}
//	}
//	@RequestMapping(value = "/remove", method = { RequestMethod.GET })
//	@ResponseBody
//	public Result removeByCluster(@RequestParam(value = "clusterId", required = true)Integer clusterId,
//			@RequestParam(value = "envId", required = true)Integer envId){
//		return clusterEnvService.remove(clusterId,envId);
//	}
}
